//
//  HZL_ZoneTableViewCell.m
//  B_Project
//
//  Created by dllo on 15/11/27.
//  Copyright © 2015年 HZL. All rights reserved.
//

#import "HZL_ZoneTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface HZL_ZoneTableViewCell ()
@property (nonatomic, retain) UIImageView *img;
@property (nonatomic, retain) UILabel *topic_name;
@end
@implementation HZL_ZoneTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.img = [[UIImageView alloc] init];
        self.img.contentMode = UIViewContentModeScaleAspectFill;
        self.img.clipsToBounds = YES;
        [self.contentView addSubview:self.img];
        
        self.topic_name = [[UILabel alloc] init];
        self.topic_name.textAlignment = NSTextAlignmentCenter;
        self.topic_name.textColor = [UIColor whiteColor];
        self.topic_name.font = [UIFont systemFontOfSize:17];
        [self.contentView addSubview:self.topic_name];
        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.img.frame = CGRectMake(10, 10, self.contentView.frame.size.width - 20, ([UIScreen mainScreen].bounds.size.height - 64 - 49 - 50) / 4.2);
    
    self.topic_name.frame = CGRectMake(0, ([UIScreen mainScreen].bounds.size.height - 64 - 49 - 50) / 4.2 / 2 , self.contentView.frame.size.width, 20);
}

- (void)setModel:(HZL_FindModel *)model
{
    if (_model != model) {
        _model = model;
    }
    
    self.topic_name.text = model.name;
    [self.img sd_setImageWithURL:[NSURL URLWithString:model.img]];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
